using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Models.ServerModels;
using Models.APIModels;

namespace DdnsServer
{
    public static class Comm
    {
        public static ApiConfigModel GetApiCfg(string api_id, string api_token, string eoe = "no", string format = "json", string lang = "cn", string server = "https://dnsapi.cn", string useragent = "LNDDNS/v 1.0 (lovesans@gmail.com)", string userId = "")
        {
            ApiConfigModel cfg = new ApiConfigModel
            {
                ApiId = api_id,
                ApiToken = api_token,
                ErrorOnEmpty = eoe,
                Format = format,
                Lang = lang,
                ServerAddress = server,
                UserAgent = useragent,
                UserId = userId
            };
            return cfg;
        }

        public static string GetClientIP()
        {
            string ip;
            //ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            //if (string.IsNullOrEmpty(ip))
            ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            return ip;
        }
    }
}